package wc

import (
	"github.com/silenceper/wechat/template"
	"time"
)

const (
	MyOpenID   = "​oXxAd1pwRErjpCgszeFSzzWnGmLU"
	ServerDown = "ySGJjhv-RKGu185B4vwVIkRapatRtoEvnrQg5q8df3s"
	/*
		{{first.DATA}}
		故障时间：{{time.DATA}}
		故障原因：{{reason.DATA}}
		{{remark.DATA}}
	*/
)

func Send(oid, TID string, data map[string]*template.DataItem) error {
	_, err := Wc.GetTemplate().Send(&template.Message{
		ToUser:     oid,
		TemplateID: TID,
		Data:       data,
	})
	return err
}

func QuickDown(where, what, err string) error {
	data := map[string]*template.DataItem{
		"first":  {Value: where + " error"},
		"time":   {Value: time.Now().Format("2006/01/02 15:04:05")},
		"reason": {Value: what},
		"remark": {Value: err}}
	return Send(MyOpenID, ServerDown, data)
}
